<?php
namespace app\index\controller;



use think\Request;
use think\Db;

class Shop extends \think\Controller
{     
  //购物首页
    public function index()
    {
      //省

      $province=Db::table('city_province')->select();

      $this->assign('province',$province);
      //搜索

      $list['Level']=2;

      $list=Db::table('product_cate')->where($list)->limit(9)->select();

      $this->assign('list',$list);

      $shoplist['Level']=1;

      $res=Db::table('product_cate')->where($shoplist)->limit(7)->select();

      $this->assign('res',$res);
      //供应

      $shopsupply=Db::table('service_supply')->alias(['service_supply' => 's','unit'=> 'u'])
                                ->join('unit',' u.unid = s.Unit')
                                ->order('ID desc')
                                ->limit(10)
                                ->select();

      $this->assign('shopsupply',$shopsupply);


      // //采购

      $product=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                ->join('unit',' u.unid = p.Unit')
                                ->limit(10)
                                ->select();

      $this->assign('product',$product);

      //最新行情
      $price=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                ->join('unit',' u.unid = p.Unit')
                                ->limit(10)
                                ->order('ID desc')
                                ->select();

      $this->assign('price',$price);

      //特产店
      $ProductCategoryID['ProductCategoryID']=240;

      $specialty=Db::table('product')->where($ProductCategoryID)->limit(6)->select();

      $this->assign('specialty',$specialty);
      


         //我的关注信息

      $data=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                ->join('unit',' u.unid = p.Unit')
                                ->order('ID desc')
                                ->limit(10)
                                ->select();

      $this->assign('data',$data);

         //特供专栏
  
      $ProductCategoryID['ProductCategoryID']=240;
      
      $supply=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                  ->join('unit',' u.unid = p.Unit')
                                  ->where($ProductCategoryID)
                                  ->limit(4)
                                  ->order('ID desc')
                                  ->select();

      $this->assign('supply',$supply);
         //农情所急
      

      $fast=Db::table('news')->limit(4)->select();

      $this->assign('fast',$fast);

      return view();

    }

          

        


         //地标
    public function gps()
    {
          //导航列表
      $id=input('id');

      $list=Db::table('product_cate')->find($id);

      $this->assign('t',$list);

      // dump($list);

      $user=Db::table('user')->limit(9)->select();

      $this->assign('user',$user);

      $data=Db::table('product')->limit(3)->select();

      $this->assign('data',$data);

      $info['BusType']=0;

      $product['ProductCategoryID']=240;

      $product=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                ->where($product)
                                ->join('unit',' u.unid = p.Unit')
                                ->order('ID desc')
                                ->paginate(20);

      $this->assign('info',$info);

      $page = $product->render();

      $this->assign('product',$product);

      $this->assign('page', $page);

      return view();
    }





    public function shopbuy()
    {
       //搜索

      $list['Level']=2;

      $list=Db::table('product_cate')->where($list)->limit(9)->select();

      $this->assign('list',$list);
      //内容
      $bustype['BusType']=1;

      $data=Db::table('product')->alias(['product'=>'p','user'=>'u','unit'=>'n'])
                                  ->where($bustype)
                                 ->field('p.ID,u.Name as username,u.ID as uid,u.Province,u.City,u.Area,p.AccountID,p.Name as productname,p.ProductCategory,p.Price,p.Unit,n.unid,n.type,p.CreateTime')
                                 ->join('user','u.ID = p.AccountID')
                                 ->join('unit',' n.unid = p.Unit')
                                 ->order('p.ID desc')
                                 ->paginate(20);

      $page = $data->render();

      $this->assign('page', $page);

      $this->assign('data',$data);

      return view();
    }






     public function shopsupply()
    {
       //搜索

      $list['Level']=2;

      $list=Db::table('product_cate')->where($list)->limit(9)->select();

      $this->assign('list',$list);

      $data=Db::table('service_supply')->alias(['service_supply'=>'s','unit'=>'n']) ->join('unit',' n.unid = s.Unit')->order('ID desc')->paginate(20);

      $page = $data->render();

      $this->assign('page', $page);

      $this->assign('data',$data);


        return view();
    }












         //购物页
    public function shop()
    {
        //商品列表+分页
      $where['SalesCategory']=3;

      $productlist=Db::table('product')->where($where)->join('unit','product.Unit=unit.unid')->order('ID desc')->paginate(12);

      $page = $productlist->render();

      $this->assign('productlist',$productlist);
       
      $this->assign('page', $page);
   
        //搜索

      $list['Level']=2;

      $list=Db::table('product_cate')->where($list)->limit(9)->select();

      $this->assign('list',$list);

      $shoplist['Level']=1;

      $res=Db::table('product_cate')->where($shoplist)->limit(6)->select();

      $this->assign('res',$res);

    	return view();
    }





    public function logo()
    {	
      //搜索

       $list['Level']=2;

       $list=Db::table('product_cate')->where($list)->limit(9)->select();

       $this->assign('list',$list);
    	 //十大热销
    	 $bustype['BusType']=0;

    	 $data=Db::table('product')->where($bustype)->limit(10)->order('ID desc')->select();

    	 $this->assign('data',$data);

       //十大创新农品
       $SalesCategory['SalesCategory']=3;

       $info=Db::table('product')->where($SalesCategory)->order('ID desc')->limit(10)->select();

       $this->assign('info',$info);

       //十大会惠农
       $shoptype['SalesCount']=3;

       $shop=Db::table('product')->where($shoptype)->order('ID desc')->limit(10)->select();

       $this->assign('shop',$shop);

       //十大飙升

       $bus['BusType']=2;

       $type=Db::table('product')->where($bustype)->limit(10)->order('ID desc')->select();

       $this->assign('type',$type);


       //十大热度品牌

       $hot=Db::table('product')->limit(10)->select();

       $this->assign('hot',$hot);


       
    	  //十大三农人物

    	 $where['BusModelID']=5;

    	 $news=Db::table('news')->where($where)->limit(10)->select();

    	 $this->assign('news',$news);

       $shop=input('ID');

       $shoplist=Db::table('news')->where($id)->limit(5)->select();

       $this->assign('shoplist',$shoplist);
        
       return view();


    }





    public function recommend()
    {

        return view();
    }







    public function show()
    {

        return view();
    }






      //购物页
    public function supply()
    {
      //搜索

      $info['Level']=1;

      $infos=Db::table('product_cate')->where($info)->limit(7)->select();

      $this->assign('infos',$infos);

      //头部导航栏
      $top['Level']=2;

      $toplist=Db::table('product_cate')->where($top)->limit(10)->select();

      $this->assign('toplist',$toplist);

      $typelist=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                   ->field('s.ID,p.Price,s.Name,s.DefaultImage,u.type')
                                   ->join('product p','p.ID = s.ProductCategoryID')
                                   ->join('unit u','s.Unit=u.unid')
                                   ->limit(5) 
                                   ->order('s.ID desc')
                                   ->select();

      $this->assign('typelist',$typelist);
      //喜欢
      $base=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                ->field('s.ID,s.Name as sname,p.Price,s.ProductCategoryName,s.Specification,s.Contact,s.City,s.Area,s.CreateTime,s.DefaultImage,s.Unit,u.type')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->join('unit u','s.Unit=u.unid')
                                ->limit(5)
                                ->select();

      $this->assign('base',$base);

      //内容+分页

      $data=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                ->field('s.ID,p.Price,s.ProductCategoryName,s.Specification,s.Contact,s.City,s.Area,s.CreateTime,s.DefaultImage,s.Unit,u.type')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->join('unit u','s.Unit=u.unid')
                                ->order('s.ID desc')
                                ->paginate(20);
      // dump($data);
      $page = $data->render();

      $this->assign('page', $page);

        // $this->assign('supply',$supply);

      $this->assign('data',$data);

      return view();
    }






    //供应详情页
    public function supplylist()
    {
      //品种

      $supply=Db::table('service_supply')->limit(9)->select();


      $this->assign('supply',$supply);
    
      //热门供应

      $typelist=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                   ->field('s.ID,p.Price,s.Name,s.DefaultImage,u.type')
                                   ->join('product p','p.ID = s.ProductCategoryID')
                                   ->join('unit u','s.Unit=u.unid')
                                   ->limit() 
                                   ->order('s.ID desc')
                                   ->select();

      $this->assign('typelist',$typelist);
      //喜欢
      $base=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                ->field('s.ID,s.Name as sname,p.Price,s.ProductCategoryName,s.Specification,s.Contact,s.City,s.Area,s.CreateTime,s.DefaultImage,s.Unit,u.type')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->join('unit u','s.Unit=u.unid')
                                ->limit(5)
                                ->select();

      $this->assign('base',$base);

      //内容
      $data=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                  ->field('s.ID,p.Price,s.ProductCategoryName,s.Specification,s.Contact,s.City,s.Area,s.CreateTime,s.DefaultImage,s.Unit,u.type')
                                  ->join('product p','p.ID = s.ProductCategoryID')
                                  ->join('unit u','s.Unit=u.unid')
                                  ->order('s.ID desc')
                                  ->paginate(20);
        //dump($data);
      $page = $data->render();

      $this->assign('page', $page);

          // $this->assign('supply',$supply);

      $this->assign('data',$data);
        

      return view();
    }





   



    //供应购买
  public  function supplymoney()
  {
      //搜索
    $list['Level']=2;

    $list=Db::table('product_cate')->where($list)->limit(9)->select();

    $this->assign('list',$list);

    //阅读
    $id=input('id');

    Db::table('news')->where('ID',$id)->setInc('PageNum');

    $news=Db::table('news')->find($id);
           
    $this->assign('news',$news);
    //内容

    $data=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                ->field('s.ID,p.MaxBuyNum,p.Content,p.Price,p.Specification as ps,s.ProductCategoryName,s.AccountName,s.Name,s.Specification as ss,s.Contact,s.CreateTime,s.DefaultImage,s.Unit,u.type')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->join('unit u','s.Unit=u.unid')
                                ->where('s.ID',$id)
                                ->order('s.ID desc')
                                ->find();
                               

    $this->assign('t',$data);

      //同类推荐
    $supply=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                ->field('s.ID,s.MinPrice,s.MaxPrice,s.Name,s.DefaultImage,u.type')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->join('unit u','s.Unit=u.unid')
                                ->limit(5)
                                ->select();

    $this->assign('supply',$supply);


      //相关分类
    

    $datalist=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p'])
                                ->field('s.ID,s.ProductCategoryName')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->limit(14)
                                ->select();

    $this->assign('datalist',$datalist);

      //精品推荐  有问题
    $ISProposed['ISProposed']=1;

    $quality=Db::table('service_supply')->alias(['service_supply'=>'s','product'=>'p','unit'=>'u'])
                                ->where($ISProposed)
                                ->field('s.ID,s.MinPrice,p.Price,s.MaxPrice,s.Name,s.DefaultImage,u.type')
                                ->join('product p','p.ID = s.ProductCategoryID')
                                ->join('unit u','s.Unit=u.unid')
                                ->limit(5)
                                ->select();

    $this->assign('quality',$quality);



    $this->assign('quality',$quality);

    $user=Db::table('user')->limit(1)->select();

    $this->assign('user',$user);


    return view();
  }





     //社区首页
   public function districtindex()
  {       //菜单
      $id['Level']=2;

      $data=Db::table('product_cate')->where($id)->limit(9)->select();

      $this->assign('data',$data);

          //热卖商品
      $hot=Db::table('product')->limit(20)->order('ID desc')->select();

      $this->assign('hot',$hot);

          //社区店
      $bustype['ProductCategoryID']=887;

      $district=Db::table('product')->where($bustype)->limit(10)->select();

      $this->assign('district',$district);

          //形象店
     
      $product=Db::table('product')->limit(10)->select();

      $this->assign('product',$product);

          //推荐店
      $info['ISProposed']=0;

      $proposed=Db::table('product')->where($info)->limit(10)->order('ID desc')->select();

      $this->assign('proposed',$proposed);

      return view();
    }






    //社区详情页
     public function districtlist()
    {
      //浏览次数
      $id=input('id');

      Db::table('product')->where('ID',$id)->setInc('PageNum');

      $news=Db::table('product')->find($id);
           
      $this->assign('news',$news);


      $info=Db::table('product')->alias(['product'=>'p','unit'=>'u'])->where('ID',$id)->join('unit','product.Unit=unit.unid')->limit(1)->find();
     
      $user=Db::table('user')->where('ID',$info['AccountID'])->find();

      $this->assign('user',$user);

      $productlist=Db::table('product')->alias(['product'=>'p','unit'=>'u'])->where('AccountID',$info['AccountID'])->join('unit u','p.Unit=u.unid')->limit(3)->order('ID desc')->select();

      $this->assign('productlist',$productlist);                                 

      $this->assign('t',$info);

     
      
      return view();

        
    }





    




    public function shopselectlist()
    {
      //搜索

       $list['Level']=2;

       $list=Db::table('product_cate')->where($list)->limit(9)->select();

       $this->assign('list',$list);

       //内容

       $id=input('ID');

       $data=Db::table('product')->alias('a')
                                  ->join('user u','u.ID=a.BusinessID')
                                  ->where($id)
                                  ->limit(3)
                                  ->select();

       $this->assign('data',$data);

       return view();
    }
 






    //商铺页
    public function productlist()
    {
      $id=input('id');
     
      $info=Db::table('product')->where('ID',$id)->join('unit','product.Unit=unit.unid')->limit(1)->find();
     
      $user=Db::table('user')->where('ID',$info['AccountID'])->find();

      $productlist=Db::table('product')->where('AccountID',$info['AccountID'])->limit(3)->order('ID desc')->select();
 
     

      $this->assign('productlist',$productlist);                                 

      $this->assign('t',$info);

      $this->assign('user',$user);
      
      return view();
    }








    public function shoplist()
    {
      //搜索
      $data=Db::table('product_cate')->where('Level',2)->limit(9)->select();

      $this->assign('data',$data);

      $Level['Level']=3;

      $product=Db::table('product_cate')->where($Level)->limit(10)->select();

      $this->assign('product',$product);


      //阅读量
      $id=input('id');

     
      Db::table('product')->where('ID',$id)->setInc('PageNum');

      $news=Db::table('product')->find($id);

      $this->assign('news',$news);
      //内容
      $id=input('id');

      $info = Db::table('product')->alias(['product' =>'p','unit'=>'n','user'=>'u'])
                                  ->where('p.id',$id)
                                  ->field('p.ID,p.ProductCategory,p.StockSize,u.Name as username,u.Province,u.City,u.Area,u.AddressDis,n.type,p.CreateTime,p.Name as productname')
                                  ->join('unit n',' n.unid = p.Unit')
                                  ->join('user u','u.ID = p.AccountID')
                                  ->find();

      $join=Db::table('product')->alias('p')
                                ->field('p.ID,u.Name as username,u.Province,u.City,p.CreateTime,p.Name as productname,p.ProductCategory')
                                ->join('user u','u.ID = p.AccountID')
                                ->limit(10)
                                ->select();

      $this->assign('join',$join);

      $this->assign('t',$info);

      return view();
    }





    public function signindex()
    {
      //最新上架
      $info=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                ->join('unit',' u.unid = p.Unit')
                                ->order('ID desc')
                                ->limit(16)
                                ->select();

      $this->assign('info',$info);
      // dump($info);

      //推荐产品
      $data=Db::table('product')->alias(['product' => 'p','unit'=> 'u'])
                                ->where('ISProposed',0)
                                ->join('unit',' u.unid = p.Unit')
                                ->order('ID desc')
                                ->limit(4)
                                ->select();

      $this->assign('data',$data);


      $Level['Level']=2;

      $list=Db::table('product_cate')->limit(9)->select();

      $this->assign('list',$list);


      return view();
    }




  



      //特产商家
    public function signhome()
    {
      $shoptype['ShopType']=3;

      $product=Db::table('product_business')->where($shoptype)->order('ID desc')->paginate(20);

      $page = $product->render();

      $this->assign('product',$product);

      $this->assign('page', $page);

      return view();
    }





    public function signlist()
    {

      $id=input('id');
     
      $info=Db::table('product')->where('ID',$id)->join('unit','product.Unit=unit.unid')->limit(1)->find();
     
      $user=Db::table('user')->where('ID',$info['AccountID'])->find();

      $productlist=Db::table('product')->where('AccountID',$info['AccountID'])->limit(3)->order('ID desc')->select();
 
      //$info=Db::table('product')->field('user.ID,product.ID,Content,DefaultImage,user.Name as uasename,product.Name as productname')->join('user','user.ID=product.AccountID')->where('product.ID',$id)  ->find();

      $this->assign('productlist',$productlist);                                 

      $this->assign('t',$info);

      $this->assign('user',$user);
      
      return view();
    }







    //商家详情页

    public function homelist()
    {
      $id=input('id');

         //商家简介
      $product=Db::table('product')->alias('p')
                                  ->join('product_business d','p.BusinessID = d.ID')
                                  ->where('d.ID',$id)
                                  ->find();
      $this->assign('t',$product);
      


        //推荐商品
       $data=Db::table('product')->alias(['product' =>'p','unit'=>'n'])
                                 ->where('ISProposed',$product['ISProposed'])
                                ->join('unit n',' n.unid = p.Unit')
                                ->order('p.ID desc')
                                ->limit(8)
                                ->select();
                                       //dump($data);

       $this->assign('data',$data);
       
       //供应
       $supply=Db::table('service_supply')->alias(['service_supply' =>'s','unit'=>'n'])
                                ->where('ProductCategoryID',$data['ProductCategoryID'])
                                 ->join('unit n',' n.unid = s.Unit')
                                // ->join('product p','p.ID = s.ProductCategoryID')
                                ->order('s.ID desc')
                                ->select();
                             
      $this->assign('supply',$supply);

      //阅读量
     
      Db::table('product_business')->where('ID',$id)->setInc('PageNum');

      $news=Db::table('product_business')->find($id);

      $this->assign('news',$news);

      return view();
    }







    public function district()
    {
      $id['ProductCategoryID']=887;

      $info=Db::table('product')->alias(['product' =>'p','user'=>'u'])
                               ->where($id)
                                ->field('p.ID,p.ProductCategoryID,u.Name as username,u.Province,u.City,u.Area,u.AddressDis,p.Business,p.DefaultImage')
                                ->join('user u','u.ID = p.AccountID')
                                ->order('p.ID desc')
                                ->paginate(5);
    
      $page = $info->render();

      $this->assign('page', $page);

      $this->assign('info',$info);
      // dump($info);
      // dump($info);

      return view();
    }





    public function shopsupplylist()
    {
      $id=input('id');
    
      $data=Db::table('service_supply')->alias(['service_supply' =>'s','unit'=>'n'])
                                ->where('s.id',$id)
                                 ->join('unit n',' n.unid = s.Unit')
                                ->order('ID desc')
                                ->find();

           //搜索
      $list['Level']=2;

      $list=Db::table('product_cate')->where($list)->limit(9)->select();

      $this->assign('list',$list);
                        
      $this->assign('t',$data);
   
      return view();
    }





    public function hometable()
    {
      $id=input('id');

      Db::table('product_business')->where('ID',$id)->setInc('PageNum');
      
      $news=Db::table('product_business')->find($id);


      $this->assign('news',$news);

      $product=Db::table('product')->alias('p')
                                  ->join('product_business d','p.BusinessID = d.ID')
                                  ->where('d.ID',$id)
                                  ->find();
                        
      $this->assign('t',$product);

      $info=Db::table('product')->alias(['product' =>'p','unit'=>'n'])
                                ->where('BusinessID',$product['BusinessID'])
                                ->field('p.ID,p.AccountID,p.Price,p.Business,p.DefaultImage,n.type')
                                ->join('unit n',' n.unid = p.Unit')
                                ->order('p.ID desc')
                               ->paginate(5);
                               // dump($info);
                             
      $page = $info->render();

      $this->assign('page', $page);
                               

      $this->assign('info',$info);

      return view();

    }





    public function phone()
    {
      $id=input('id');

      Db::table('product_business')->where('ID',$id)->setInc('PageNum');

      $news=Db::table('product_business')->find($id);

      $this->assign('news',$news);
     
      $product=Db::table('product')->alias('p')
                                  ->join('product_business d','p.BusinessID = d.ID')
                                  ->where('d.ID',$id)
                                  ->find();

      $this->assign('t',$product);



      return view();
    }









    public function supplyintro()
    {

       //阅读量
      $id=input('id');

      Db::table('product_business')->where('ID',$id)->setInc('PageNum');

      $news=Db::table('product_business')->find($id);
           
      $this->assign('news',$news);

      $product=Db::table('product')->alias('p')
                                  ->join('product_business d','p.BusinessID = d.ID')
                                  ->where('d.ID',$id)
                                  ->find();
                        
       $this->assign('t',$product);

       return view();
    }






    public function shopselect()
    {

      $info = Db::table('product')->alias(['product' =>'p','unit'=>'n','user'=>'u'])
                                   ->field('p.ID,u.Name as username,p.Name as pname,p.Price,p.ProductCategory,p.Specification,p.CreateTime,p.DefaultImage,u.Province,u.City,u.Area,u.AddressDis,n.type')
                                  ->join('unit n',' n.unid = p.Unit')
                                  ->join('user u','u.ID = p.AccountID')
                                  ->order('p.ID desc')
                                  ->paginate(5);

      $page = $info->render();

      $this->assign('page', $page);
                               

      $this->assign('info',$info);

      return view();
    }






    public function nine()
    {

      return view();
    }


    public function mesupply()
    {
      return view();
    }




    public function product()
    {

      return view();
    }
    


  public function soheshop()
    {
      $data=Db::table('product')->alias(['product' =>'p','user'=>'u'])
      ->field('p.ID,u.Name as username,p.Name as pname,u.Province,u.City,p.CreateTime,p.Business,p.ProductCategory')
                                ->join('user u','u.ID = p.AccountID')
                                ->order('p.ID desc')
                                ->paginate(10);
    
      $page = $data->render();

      $this->assign('page', $page);

      $this->assign('data',$data);
                               

      return view();
    }







    public function productsupply()
    {
        $id=input('id');

        $product=Db::table('product')->alias('p')
                                  ->join('product_business d','p.BusinessID = d.ID')
                                  ->where('d.ID',$id)
                                  ->find();
                        

        $this->assign('t',$product);

        Db::table('product_business')->where('ID',$id)->setInc('PageNum');

        $news=Db::table('product_business')->find($id);

        $this->assign('news',$news);

         //供应
        $info=Db::table('service_supply')->alias(['service_supply' =>'s','unit'=>'n'])
                                ->where('ProductCategoryID',$data['ProductCategoryID'])
                                 ->join('unit n',' n.unid = s.Unit')
                                // ->join('product p','p.ID = s.ProductCategoryID')
                                ->order('s.ID desc')
                                ->select();
                             
        $this->assign('info',$info);

        return view();
    }






    public function shophome()
    {
       $list['Level']=2;

       $list=Db::table('product_cate')->where($list)->limit(9)->select();

       $this->assign('list',$list);

       $data=Db::table('city_city')->limit('7')->select();

       $this->assign('data',$data);
       // $id=input('id');
       $info=Db::table('product')->alias(['product' =>'p','user'=>'u'])
                                ->field('p.ID,p.Business,p.DefaultImage,u.Name as username,u.Province,u.City,u.Area,u.AddressDis')
                                ->join('user u','u.ID = p.AccountID')
                                 ->paginate(5);
    
      $page = $info->render();

      $this->assign('page', $page);

      $this->assign('info',$info);
      


     return view();
    }








    public function peasant()
    {     
      //搜索
       $list['Level']=2;

       $list=Db::table('product_cate')->where($list)->limit(9)->select();

       $this->assign('list',$list);

       $data['ProductCategoryID']=240;

       $product=Db::table('product')->alias(['product' =>'p','user'=>'u','unit'=>'n'])
                                    ->join('unit n',' n.unid = p.Unit')
                                    ->where($data)
                                    ->order('ID desc')
                                   ->paginate(12);
    
      $page = $product->render();

      $this->assign('page', $page);

      $this->assign('product',$product);
                        
      return view();
    }








    public function tsupply()
    {
       //搜索

       $list['Level']=2;

       $list=Db::table('product_cate')->where($list)->limit(9)->select();

       $this->assign('list',$list);

       $data['ProductCategoryID']=240;

       $product=Db::table('product')->alias(['product' =>'p','user'=>'u','unit'=>'n'])
                                    ->join('unit n',' n.unid = p.Unit')
                                    ->where($data)
                                    ->order('ID desc')
                                   ->paginate(4);
    
      $page = $product->render();

      $this->assign('page', $page);

      $this->assign('product',$product);
                        
      return view();
    }









    public function  shoptools()
    {
      //搜索

       $list['Level']=2;

       $list=Db::table('product_cate')->where($list)->limit(9)->select();

       $this->assign('list',$list);


       $bustype['BusType']=2;

       $data=Db::table('product')->alias(['product' =>'p','unit'=>'n'])
                                    ->join('unit n',' n.unid = p.Unit')
                                    ->where($bustype)
                                    ->order('ID desc')
                                   ->paginate(20);
    
      $page = $data->render();

      $this->assign('page', $page);

      $this->assign('data',$data);



      return view();
}










//租赁服务
public function hire()
{
  $data=Db::table('service_Lease')->order('ID desc')
                                   ->paginate(20);
  $page = $data->render();

  $this->assign('page', $page);


  $this->assign('data',$data);

  return view();
}








public function hirelist()
{

  $id=input('id');

  $data=Db::table('service_Lease') ->where('ID',$id)->find();

  $this->assign('t',$data);

  return view();
}






//大宗定制
public function customize()
{
  $data=Db::table('service_custom') ->order('ID desc')->paginate(20);

  $page = $data->render();

  $this->assign('page', $page);

  $this->assign('data',$data);

  return view();
}





public function customizelist()
{
  $id=input('id');

  $data=Db::table('service_custom')->where('ID',$id)->find();

  $this->assign('t',$data);

  return view();
}





//集团采购

public function bloc()
{
  return view();
}





public function bloclist()
{

  return view();
}





}